package haemers.reflection.tests 
{
	import flash.utils.describeType;
	import flash.utils.Dictionary;
	import haemers.reflection.data.vo.AccessorVO;
	import nl.haemers.data.reflection.Accessors;
	import nl.haemers.data.reflection.IAccessor;
	import org.flexunit.Assert;
	/**
	 * ...
	 * @author Jonathan
	 */
	
	public class AccessorsTest 
	{
		private var _mockData:AccessorVO;
		private var _description:XML;
		private var _accessors:Accessors;
		
		/** Public methods **/
		[Before]
		public function setup() : void
		{
			_mockData = new AccessorVO();
			_description = describeType(_mockData);
			_accessors = new Accessors(_description);
		}
		
		[Test]
		public function testCollection() : void
		{
			Assert.assertTrue(_accessors.getAccessors() is Dictionary);
			Assert.assertNotNull(_accessors.getAccessors());
			Assert.assertNotNull(_accessors.getAccessors()["id"]);
		}
		
		[Test]
		public function testLookUp() : void
		{
			Assert.assertNotNull(_accessors.getAccessor("id"));
			Assert.assertTrue(_accessors.getAccessor("id") is IAccessor);
			Assert.assertTrue(_accessors.hasAccessor("id"));
			
			Assert.assertTrue(_accessors.hasAccessor("ignoredProperty"));
		}
		
		[Test]
		public function testSerializeName() : void
		{
			Assert.assertFalse(_accessors.hasAccessor("nested"));
			Assert.assertTrue(_accessors.hasAccessor("child"));
			
			Assert.assertNull(_accessors.getAccessor("nested"));
			Assert.assertNotNull(_accessors.getAccessor("child"));
		}
		
		[After]
		public function teardown() : void
		{
			_description = null;
			_accessors = null;
		}
		
		/** Getters & Setters **/
		
		/** Protected methods **/
		
		/** Private methods **/
	}

}